package com.qf.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.qf.entity.Goods;
import com.qf.service.ISearchService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @author 刘亚康
 * @Date 2020/4/4
 * @Version 1.0'
 * @Description
 */
@Slf4j
@Controller
public class SearchController {

    @Reference
    private ISearchService searchService;

    @RequestMapping("/searchGoods")
    public String searchGoods(String key, ModelMap map){
        log.info("需要查询的key:"+key);
        List<Goods> goodsList = searchService.getGoodsListByKey(key);
        map.put("goodsList",goodsList);
        log.info("查询到的商品有："+goodsList.toString());
        return "searchGoods";
    }
}
